<?php

function GetLinks($xml_links){

	$res2 = '';
	if($xml_links->profile){
			foreach($xml_links->profile as $link){
			  $res2 .= '<li class="links"><a href="'.htmlspecialchars($link->url).'">'.$link->name.'</a></li>'."\n";
			}
		}

		if(!empty($res2)){ echo '<ul class="info_profile">'.$res2.'</ul>'; }

	}
function getZiki($pseudo){
$db = mysql_connect("localhost","root", "") or die("Impossible de se connecter a la bdd");
		mysql_select_db("tutoriel",$db) or die("Impossible de se connecter a la table");

		$table_name = "customer";
		$sql = "SELECT ziki_url FROM $table_name 
			  WHERE user_name='$pseudo'
			  ";      #19
		$result = mysql_query($sql,$db);
		
$res = mysql_fetch_array($result); echo $res['ziki_url'];

if($res['ziki_url'] == ""){echo "Nous n'avons pas encore d'information disponible (l'utilisateur n'a pas encore enregistr&eacute; d'adresse Ziki.";}
	else {$fileok = $pseudo.".xml";
   
	$ch = curl_init($res['ziki_url'].".xml");
	$fp = fopen($fileok, "w");
   
	curl_setopt($ch, CURLOPT_FILE, $fp);
	curl_setopt($ch, CURLOPT_HEADER, 0);
   
	curl_exec($ch);
	curl_close($ch);
	fclose($fp);
   
   
   
	ini_set('max_execution_time', 0);
	$xml = simplexml_load_file($fileok);
   
	$ziki = $xml->ziki;
   
			$nom = $ziki->first_name.' '.$ziki->last_name;
			//$nom_complet = ($ziki->first_name.$ziki->last_name == '') ? $ziki->nickname : $nom.' <em>dit '.$ziki->nickname.'</em>';
   
			$first_line = ($ziki->gender == 'male') ? 'Homme' : 'Femme';
			$first_line .= (substr($ziki->birthday,0,4) == 0000) ? '' : ', '.(date('Y') - substr($ziki->birthday,0,4)).' ans';
			$first_line .= ($ziki->city == '') ? '' : ', '.$ziki->city;
			$first_line .= ($ziki->country == '') ? '' : ', '.$ziki->country.
			' | <a href="http://www.ziki.com/fr/people/'.$ziki->nickname.'.vcf">'.
			'<span id="vcard">Vcard</span></a>';
   
			$website = ($ziki->website == '') ? '' : 'Site : <a href="'.$ziki->website.'">'.$ziki->website.'</a>';
			$citation = ($ziki->baseline != '') ? '<small><em>'.$ziki->baseline.'</em></small>' : '';
   
			$res = '<img src="'.$ziki->photos->medium.'" alt="Photo de '.$ziki->nickname.'" class="float_left" />'."\n".
			'<ul class="info_profile"><li><h5>'.$nom.'</h5></li>'."\n".
			'<li>'.$first_line.'</li>'."\n".
			'<li>'.$citation.'</li>'."\n".
			'<li>'.$website.'</li></ul>'."\n";
   
   
		echo "$res";	
		echo "<br/>";
		echo "<h5 class=\"clearboth\">Mes liens</h5>";
		GetLinks($ziki->profiles);
}}
?>